package com.ton.utils;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Xxl-Job 手动工具类
 * 自动登录 - 自动添加任务 - 手动调用任务 等等
 */
@Component
@Data
public class XxlJobAutoUtils {
    //登录的Cookie
    private final Map<String,String> loginCookie=new HashMap<>();


    /**
     * 登录请求
     */
    public void login() {
//        String url=adminAddresses+"/login";
//        HttpResponse response = HttpRequest.post(url)
//                .form("userName",username)
//                .form("password",password)
//                .execute();
//        List<HttpCookie> cookies = response.getCookies();
//        Optional<HttpCookie> cookieOpt = cookies.stream()
//                .filter(cookie -> cookie.getName().equals("XXL_JOB_LOGIN_IDENTITY")).findFirst();
//        if (!cookieOpt.isPresent())
//            throw new RuntimeException("get xxl-job cookie error!");
//
//        String value = cookieOpt.get().getValue();
//        loginCookie.put("XXL_JOB_LOGIN_IDENTITY",value);
    }
}
